package com.slz3.business;

import com.slz3.business.frame.module.Services;
import com.slz3.business.frame.response.ResInfo;
import com.slz3.business.module.afterSaleManagement.aftApplyOrder.AftApplyOrderHandler;
import com.slz3.business.module.afterSaleManagement.aftApplyOrder.AftApplyOrderRouter;
import com.slz3.business.module.afterSaleManagement.aftApplyOrderLine.AftApplyOrderLineHandler;
import com.slz3.business.module.afterSaleManagement.aftApplyOrderLine.AftApplyOrderLineRouter;
import com.slz3.business.module.afterSaleManagement.aftWorkOrder.AftWorkOrderHandler;
import com.slz3.business.module.afterSaleManagement.aftWorkOrder.AftWorkOrderRouter;
import com.slz3.business.module.apiAliyun.aliyunOSS.AliyunOSSHandler;
import com.slz3.business.module.apiAliyun.aliyunOSS.AliyunOSSRouter;
import com.slz3.business.module.configManagement.conFeedback.ConFeedbackHandler;
import com.slz3.business.module.configManagement.conFeedback.ConFeedbackRouter;
import com.slz3.business.module.configManagement.conShareManage.ConShareManageHandler;
import com.slz3.business.module.configManagement.conShareManage.ConShareManageRouter;
import com.slz3.business.module.configManagement.conSiteCity.ConSiteCityHandler;
import com.slz3.business.module.configManagement.conSiteCity.ConSiteCityRouter;
import com.slz3.business.module.configManagement.conSiteCounty.ConSiteCountyHandler;
import com.slz3.business.module.configManagement.conSiteCounty.ConSiteCountyRouter;
import com.slz3.business.module.configManagement.conSiteProvince.ConSiteProvinceHandler;
import com.slz3.business.module.configManagement.conSiteProvince.ConSiteProvinceRouter;
import com.slz3.business.module.configManagement.conVersion.ConVersionHandler;
import com.slz3.business.module.configManagement.conVersion.ConVersionRouter;
import com.slz3.business.module.configManagement.conZoneManage.ConZoneManageHandler;
import com.slz3.business.module.configManagement.conZoneManage.ConZoneManageRouter;
import com.slz3.business.module.configManagement.conZoneTemplate.ConZoneTemplateHandler;
import com.slz3.business.module.configManagement.conZoneTemplate.ConZoneTemplateRouter;
import com.slz3.business.module.configManagement.conZoneType.ConZoneTypeHandler;
import com.slz3.business.module.configManagement.conZoneType.ConZoneTypeRouter;
import com.slz3.business.module.drawManagement.draFreeLottery.DraFreeLotteryHandler;
import com.slz3.business.module.drawManagement.draFreeLottery.DraFreeLotteryRouter;
import com.slz3.business.module.drawManagement.draIntegralLottery.DraIntegralLotteryHandler;
import com.slz3.business.module.drawManagement.draIntegralLottery.DraIntegralLotteryRouter;
import com.slz3.business.module.drawManagement.draParticipateMember.DraParticipateMemberHandler;
import com.slz3.business.module.drawManagement.draParticipateMember.DraParticipateMemberRouter;
import com.slz3.business.module.drawManagement.draUserNumber.DraUserNumberHandler;
import com.slz3.business.module.drawManagement.draUserNumber.DraUserNumberRouter;
import com.slz3.business.module.financeManagement.finFinanceManage.FinFinanceManageHandler;
import com.slz3.business.module.financeManagement.finFinanceManage.FinFinanceManageRouter;
import com.slz3.business.module.financeManagement.finReconciliationManage.FinReconciliationManageHandler;
import com.slz3.business.module.financeManagement.finReconciliationManage.FinReconciliationManageRouter;
import com.slz3.business.module.goodsManagement.baseGoods.BaseGoodsHandler;
import com.slz3.business.module.goodsManagement.baseGoods.BaseGoodsRouter;
import com.slz3.business.module.goodsManagement.gooAttribute.GooAttributeHandler;
import com.slz3.business.module.goodsManagement.gooAttribute.GooAttributeRouter;
import com.slz3.business.module.goodsManagement.gooAttributeValue.GooAttributeValueHandler;
import com.slz3.business.module.goodsManagement.gooAttributeValue.GooAttributeValueRouter;
import com.slz3.business.module.goodsManagement.gooBaseGoodsAttribute.GooBaseGoodsAttributeHandler;
import com.slz3.business.module.goodsManagement.gooBaseGoodsAttribute.GooBaseGoodsAttributeRouter;
import com.slz3.business.module.goodsManagement.gooBaseGoodsAttributeValue.GooBaseGoodsAttributeValueHandler;
import com.slz3.business.module.goodsManagement.gooBaseGoodsAttributeValue.GooBaseGoodsAttributeValueRouter;
import com.slz3.business.module.goodsManagement.gooBaseGoodsSpecification.GooBaseGoodsSpecificationHandler;
import com.slz3.business.module.goodsManagement.gooBaseGoodsSpecification.GooBaseGoodsSpecificationRouter;
import com.slz3.business.module.goodsManagement.gooBaseGoodsSpecificationValue.GooBaseGoodsSpecificationValueHandler;
import com.slz3.business.module.goodsManagement.gooBaseGoodsSpecificationValue.GooBaseGoodsSpecificationValueRouter;
import com.slz3.business.module.goodsManagement.gooBrand.GooBrandHandler;
import com.slz3.business.module.goodsManagement.gooBrand.GooBrandRouter;
import com.slz3.business.module.goodsManagement.gooBrandRecommendGoods.GooBrandRecommendGoodsHandler;
import com.slz3.business.module.goodsManagement.gooBrandRecommendGoods.GooBrandRecommendGoodsRouter;
import com.slz3.business.module.goodsManagement.gooGoods.GooGoodsHandler;
import com.slz3.business.module.goodsManagement.gooGoods.GooGoodsRouter;
import com.slz3.business.module.goodsManagement.gooInWarehouse.GooInWarehouseHandler;
import com.slz3.business.module.goodsManagement.gooInWarehouse.GooInWarehouseRouter;
import com.slz3.business.module.goodsManagement.gooInventory.GooInventoryHandler;
import com.slz3.business.module.goodsManagement.gooInventory.GooInventoryRouter;
import com.slz3.business.module.goodsManagement.gooOutWarehouse.GooOutWarehouseHandler;
import com.slz3.business.module.goodsManagement.gooOutWarehouse.GooOutWarehouseRouter;
import com.slz3.business.module.goodsManagement.gooTypeLevel1.GooTypeLevel1Handler;
import com.slz3.business.module.goodsManagement.gooTypeLevel1.GooTypeLevel1Router;
import com.slz3.business.module.goodsManagement.gooTypeLevel2.GooTypeLevel2Handler;
import com.slz3.business.module.goodsManagement.gooTypeLevel2.GooTypeLevel2Router;
import com.slz3.business.module.instantMessaging.insMessaging.InsMessagingHandler;
import com.slz3.business.module.instantMessaging.insMessaging.InsMessagingRouter;
import com.slz3.business.module.memberManagement.memAppKey.MemAppKeyHandler;
import com.slz3.business.module.memberManagement.memAppKey.MemAppKeyRouter;
import com.slz3.business.module.memberManagement.memCollect.MemCollectHandler;
import com.slz3.business.module.memberManagement.memCollect.MemCollectRouter;
import com.slz3.business.module.memberManagement.memJifen.MemJifenHandler;
import com.slz3.business.module.memberManagement.memJifen.MemJifenRouter;
import com.slz3.business.module.memberManagement.memMember.MemMemberHandler;
import com.slz3.business.module.memberManagement.memMember.MemMemberRouter;
import com.slz3.business.module.memberManagement.memPoint.MemPointHandler;
import com.slz3.business.module.memberManagement.memPoint.MemPointRouter;
import com.slz3.business.module.memberManagement.memRaffleTicket.MemRaffleTicketHandler;
import com.slz3.business.module.memberManagement.memRaffleTicket.MemRaffleTicketRouter;
import com.slz3.business.module.memberManagement.memRecord.MemRecordHandler;
import com.slz3.business.module.memberManagement.memRecord.MemRecordRouter;
import com.slz3.business.module.memberManagement.memShippingAddress.MemShippingAddressHandler;
import com.slz3.business.module.memberManagement.memShippingAddress.MemShippingAddressRouter;
import com.slz3.business.module.memberManagement.memShoppingCar.MemShoppingCarHandler;
import com.slz3.business.module.memberManagement.memShoppingCar.MemShoppingCarRouter;
import com.slz3.business.module.memberManagement.memThirdLoginInfo.MemThirdLoginInfoHandler;
import com.slz3.business.module.memberManagement.memThirdLoginInfo.MemThirdLoginInfoRouter;
import com.slz3.business.module.messageManagement.mesCreate.MesCreateHandler;
import com.slz3.business.module.messageManagement.mesCreate.MesCreateRouter;
import com.slz3.business.module.messageManagement.mesLog.MesLogHandler;
import com.slz3.business.module.messageManagement.mesLog.MesLogRouter;
import com.slz3.business.module.messageManagement.mesTemplate.MesTemplateHandler;
import com.slz3.business.module.messageManagement.mesTemplate.MesTemplateRouter;
import com.slz3.business.module.messageManagement.mesType.MesTypeHandler;
import com.slz3.business.module.messageManagement.mesType.MesTypeRouter;
import com.slz3.business.module.orderManagement.ordOrder.OrdOrderHandler;
import com.slz3.business.module.orderManagement.ordOrder.OrdOrderRouter;
import com.slz3.business.module.orderManagement.ordOrderLine.OrdOrderLineHandler;
import com.slz3.business.module.orderManagement.ordOrderLine.OrdOrderLineRouter;
import com.slz3.business.module.orderManagement.ordOrderLogistics.OrdOrderLogisticsHandler;
import com.slz3.business.module.orderManagement.ordOrderLogistics.OrdOrderLogisticsRouter;
import com.slz3.business.module.orderManagement.ordPayDetail.OrdPayDetailHandler;
import com.slz3.business.module.orderManagement.ordPayDetail.OrdPayDetailRouter;
import com.slz3.business.module.orderManagement.ordRefund.OrdRefundHandler;
import com.slz3.business.module.orderManagement.ordRefund.OrdRefundRouter;
import com.slz3.business.module.socialManagement.socArticle.SocArticleHandler;
import com.slz3.business.module.socialManagement.socArticle.SocArticleRouter;
import com.slz3.business.module.socialManagement.socDianzan.SocDianzanHandler;
import com.slz3.business.module.socialManagement.socDianzan.SocDianzanRouter;
import com.slz3.business.module.socialManagement.socLife.SocLifeHandler;
import com.slz3.business.module.socialManagement.socLife.SocLifeRouter;
import com.slz3.business.module.socialManagement.socShow.SocShowHandler;
import com.slz3.business.module.socialManagement.socShow.SocShowRouter;
import com.slz3.business.module.socialManagement.socSign.SocSignHandler;
import com.slz3.business.module.socialManagement.socSign.SocSignRouter;
import com.slz3.business.module.systemManagement.sysFunction.SysFunctionHandler;
import com.slz3.business.module.systemManagement.sysFunction.SysFunctionRouter;
import com.slz3.business.module.systemManagement.sysMenu.SysMenuHandler;
import com.slz3.business.module.systemManagement.sysMenu.SysMenuRouter;
import com.slz3.business.module.systemManagement.sysOrganize.SysOrganizeHandler;
import com.slz3.business.module.systemManagement.sysOrganize.SysOrganizeRouter;
import com.slz3.business.module.systemManagement.sysPermissions.SysPermissionsHandler;
import com.slz3.business.module.systemManagement.sysPermissions.SysPermissionsRouter;
import com.slz3.business.module.systemManagement.sysRole.SysRoleHandler;
import com.slz3.business.module.systemManagement.sysRole.SysRoleRouter;
import com.slz3.business.module.systemManagement.sysRoleMenu.SysRoleMenuHandler;
import com.slz3.business.module.systemManagement.sysRoleMenu.SysRoleMenuRouter;
import com.slz3.business.module.systemManagement.sysUser.SysUserHandler;
import com.slz3.business.module.systemManagement.sysUser.SysUserRouter;
import com.slz3.business.module.systemManagement.sysUser.domain.SysUser;
import com.slz3.business.module.systemManagement.sysUser.steward.SysUserConverter;
import com.slz3.business.module.templateExample.temStyle1.TemStyle1Handler;
import com.slz3.business.module.templateExample.temStyle1.TemStyle1Router;
import com.slz3.business.module.versions.VersionsHandler;
import com.slz3.business.module.versions.VersionsRouter;
import com.slz3.business.module.wmsManagement.wmsPurchaseOrderSelf.WmsPurchaseOrderSelfHandler;
import com.slz3.business.module.wmsManagement.wmsPurchaseOrderSelf.WmsPurchaseOrderSelfRouter;
import com.slz3.business.module.wmsManagement.wmsPurchaseOrderThree.WmsPurchaseOrderThreeHandler;
import com.slz3.business.module.wmsManagement.wmsPurchaseOrderThree.WmsPurchaseOrderThreeRouter;
import com.slz3.business.module.wmsManagement.wmsStockDetail.WmsStockDetailHandler;
import com.slz3.business.module.wmsManagement.wmsStockDetail.WmsStockDetailRouter;
import com.slz3.business.module.wmsManagement.wmsStockOut.WmsStockOutHandler;
import com.slz3.business.module.wmsManagement.wmsStockOut.WmsStockOutRouter;
import com.slz3.business.module.wmsManagement.wmsStockPut.WmsStockPutHandler;
import com.slz3.business.module.wmsManagement.wmsStockPut.WmsStockPutRouter;
import com.slz3.business.module.wmsManagement.wmsStockTransfer.WmsStockTransferHandler;
import com.slz3.business.module.wmsManagement.wmsStockTransfer.WmsStockTransferRouter;
import com.slz3.business.module.wmsManagement.wmsTraysManage.WmsTraysManageHandler;
import com.slz3.business.module.wmsManagement.wmsTraysManage.WmsTraysManageRouter;
import com.slz3.business.module.wmsManagement.wmsWarehouseManage.WmsWarehouseManageHandler;
import com.slz3.business.module.wmsManagement.wmsWarehouseManage.WmsWarehouseManageRouter;
import com.slz3.business.module.wmsManagement.wmsWarningConfig.WmsWarningConfigHandler;
import com.slz3.business.module.wmsManagement.wmsWarningConfig.WmsWarningConfigRouter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.web.reactive.function.server.HandlerFilterFunction;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;

import java.util.HashSet;
import java.util.Set;

import static org.springframework.web.reactive.function.server.RequestPredicates.path;
import static org.springframework.web.reactive.function.server.RouterFunctions.nest;

//this line is work for import,don't remove
import com.slz3.business.module.wmsManagement.wmsStockOutItems.WmsStockOutItemsRouter;
import com.slz3.business.module.wmsManagement.wmsStockOutItems.WmsStockOutItemsHandler;
import com.slz3.business.module.wmsManagement.wmsPurchaseOrderLine.WmsPurchaseOrderLineRouter;
import com.slz3.business.module.wmsManagement.wmsPurchaseOrderLine.WmsPurchaseOrderLineHandler;
import com.slz3.business.module.wmsManagement.wmsStockDetailItems.WmsStockDetailItemsRouter;
import com.slz3.business.module.wmsManagement.wmsStockDetailItems.WmsStockDetailItemsHandler;
import com.slz3.business.module.wmsManagement.wmsStockDetailItems.WmsStockDetailItemsRouter;
import com.slz3.business.module.wmsManagement.wmsStockDetailItems.WmsStockDetailItemsHandler;

/**
 * 根路由
 */
@Configuration
@Order(1)
public class BusinessRouter {

    private static final String VERSIONS = "/versions";

    // 社交管理模块 - 觅生活晒图
    private static final String SOC_LIFE = "/socialManagement/socLife"; // tzw_life
    // 社交管理模块 - 首页晒单表
    private static final String SOC_SHOW = "/socialManagement/socShow"; // tzw_show
    // 社交管理模块 - 签到
    private static final String SOC_SIGN = "/socialManagement/socSign"; // tzw_sign
    // 社交管理模块 - 圈子点赞
    private static final String SOC_DIANZAN = "/socialManagement/socDianzan"; // tzw_dianzan - data source only from api
    // 社交管理模块 - 文章
    private static final String SOC_ARTICLE = "/socialManagement/socArticle";

    // 消息管理模块 - 消息类型
    private static final String MES_TYPE = "/messageManagement/mesType";
    // 消息管理模块 - 消息模板
    private static final String MES_TEMPLATE = "/messageManagement/mesTemplate";
    // 消息管理模块 - 消息日志
    private static final String MES_LOG = "/messageManagement/mesLog";
    //消息管理模块 - 消息生成
    private static final String MES_CREATE = "/messageManagement/mesCreate";

    // 配置管理模块 - 专区模板
    private static final String CON_ZONE_TEMPLATE = "/configManagement/conZoneTemplate";
    // 配置管理模块 - 专区类型
    private static final String CON_ZONE_TYPE = "/configManagement/conZoneType";
    // 配置管理模块 - 专区管理
    private static final String CON_ZONE_MANAGE = "/configManagement/conZoneManage";
    // 配置管理模块 - 县
    private static final String CON_SITE_COUNTY = "/configManagement/conSiteCounty"; // county
    // 配置管理模块 - 市
    private static final String CON_SITE_CITY = "/configManagement/conSiteCity"; // city
    // 配置管理模块 - 省
    private static final String CON_SITE_PROVINCE = "/configManagement/conSiteProvince"; // province
    // 配置管理模块 - 版本管理
    private static final String CON_VERSION = "/configManagement/conVersion";
    // TODO 配置管理模块 - 意见反馈
    private static final String CON_FEEDBACK = "/configManagement/conFeedback";
    // TODO 配置管理模块 - 分享管理
    private static final String CON_SHARE_MANAGE = "/configManagement/conShareManage";

    // TODO 商品管理模块 - 基础商品
    private static final String BASE_GOODS = "/goodsManagement/baseGoods";

    // TODO 商品管理模块 - 商品规格
    private static final String GOO_BASE_GOODS_SPECIFICATION = "/goodsManagement/gooBaseGoodsSpecification";

    // TODO 商品管理模块 - 商品规格属性值
    private static final String GOO_BASE_GOODS_SPECIFICATION_VALUE = "/goodsManagement/gooBaseGoodsSpecificationValue";

    // 商品管理模块 - 商品
    private static final String GOO_GOODS = "/goodsManagement/gooGoods"; // tzw_item
    // 商品管理模块 - 品牌表
    private static final String GOO_BRAND = "/goodsManagement/gooBrand"; // tzw_brand
    // TODO 商品管理模块 - 品牌推荐商品表
    private static final String GOO_BRAND_RECOMMEND_GOODS = "/goodsManagement/gooBrandRecommendGoods";
    // 商品管理模块 - 一级分类
    private static final String GOO_TYPE_LEVE1 = "/goodsManagement/gooTypeLevel1"; // tzw_one_type
    // 商品管理模块 - 二级分类orderManagement/ordPayDetail
    private static final String GOO_TYPE_LEVE2 = "/goodsManagement/gooTypeLevel2"; // tzw_two_type
    // TODO 商品属性管理
    private static final String GOO_ATTRIBUTE = "/goodsManagement/gooAttribute";
    // TODO 商品属性值管理
    private static final String GOO_ATTRIBUTE_VALUE = "/goodsManagement/gooAttributeValue";
    // 商品管理 - 库存管理 —— v1.0 简单的库存管理，wms上线后要废弃。
    private static final String GOO_INVENTORY = "/goodsManagement/gooInventory";
    // TODO 商品管理 - 入库管理 —— v1.0 简单的入库管理，wms上线后要废弃。
    private static final String GOO_IN_WAREHOUSE = "/goodsManagement/gooInWarehouse";
    // TODO 商品管理 - 出库管理 —— v1.0 简单的入库管理，wms上线后要废弃。
    private static final String GOO_OUT_WAREHOUSE = "/goodsManagement/gooOutWarehouse";

    //商品管理 - 基础商品属性
    private static final String GOO_BASE_GOODS_ATTRIBUTE = "/goodsManagement/gooBaseGoodsAttribute";

    //商品管理 - 基础商品属性值
    private static final String GOO_BASE_GOODS_ATTRIBUTE_VALUE = "/goodsManagement/gooBaseGoodsAttributeValue";

    // 订单管理模块 - 订单
    private static final String ORD_ORDER = "/orderManagement/ordOrder"; // tzw_pay - data source only from api - 总支付表
    // 订单管理模块 - 订单行
    private static final String ORD_ORDER_LINE = "/orderManagement/ordOrderLine"; // tzw_order - 订单表
    // 订单管理模块 - 退款
    private static final String ORD_REFUND = "/orderManagement/ordRefund"; // tzw_order_return
    // TODO 订单管理模块 - 订单支付详情（支付方式、支付状态……）
    private static final String ORD_PAY_DETAIL = "/orderManagement/ordPayDetail";

    private static final String ORD_ORDER_LOGISTICS = "/orderManagement/ordOrderLogistics";

    // TODO 售后管理模块 - 售后申请
    public static final String AFT_APPLY_ORDER = "/afterSaleManagement/aftApplyOrder";
    // TODO 售后详情管理模块 - 售后申请详情
    public static final String AFT_APPLY_ORDER_LINE = "/afterSaleManagement/aftApplyOrderLine";
    // TODO 售后管理模块 - 售后工单
    private static final String AFT_WORK_ORDER = "/afterSaleManagement/aftWorkOrder";

    // TODO 仓储管理模块 - 采购单（自营）
    private static final String WMS_PURCHASE_ORDER_SELF = "/wmsManagement/wmsPurchaseOrderSelf";
    // 仓库管理模块--采购单行信息
    private static final String WMS_PURCHASE_ORDER_LINE = "/wmsManagement/wmsPurchaseOrderLine";
    // TODO 仓储管理模块 - 采购申请（第三方）
    private static final String WMS_PURCHASE_ORDER_THREE = "/wmsManagement/wmsPurchaseOrderThree";
    // TODO 仓储管理模块 - 入库管理
    private static final String WMS_STOCK_PUT = "/wmsManagement/wmsStockPut";
    // TODO 仓储管理模块 - 调拨管理
    private static final String WMS_STOCK_TRANSFER = "/wmsManagement/wmsStockTransfer";
    // TODO 仓储管理模块 - 出库管理
    private static final String WMS_STOCK_OUT = "/wmsManagement/wmsStockOut";
    // TODO 仓储管理模块 - 出库单详细
    private static final String WMS_STOCK_OUT_ITEMS = "/wmsManagement/wmsStockOutItems";
    // TODO 仓储管理模块 - 库存出入明细
    private static final String WMS_STOCK_DETAIL = "/wmsManagement/wmsStockDetail";
    // TODO 仓储管理模块 - 库存出入明细子表
    private static final String WMS_STOCK_DETAIL_ITEMS = "/wmsManagement/wmsStockDetailItems";
    // TODO 仓储管理模块 - 仓库管理
    private static final String WMS_WAREHOUSE_MANAGE = "/wmsManagement/wmsWarehouseManage";
    // TODO 仓储管理模块 - 货位管理
    private static final String WMS_TRAYS_MANAGE = "/wmsManagement/wmsTraysManage";
    // TODO 仓储管理模块 - 预警设置
    private static final String WMS_WARNING_CONFIG = "/wmsManagement/wmsWarningConfig";

    //会员管理模块 - 用户appKey
    private static final String MEM_APP_KEY = "/memberManagement/memAppKey";
    // 会员管理模块 - 会员
    private static final String MEM_MEMBER = "/memberManagement/memMember"; // user
    // 会员管理模块 - 第三方登录信息
    private static final String MEM_THIRD_LOGIN_INFO = "/memberManagement/memThirdLoginInfo"; // third_user - data source only from api
    // 会员管理模块 - 积分明细
    private static final String MEM_JIFEN = "/memberManagement/memJifen"; // tzw_jifen - data source only from api
    //【REMOVE】 会员管理模块 - 消费记录
    private static final String MEM_RECORD = "/memberManagement/memRecord"; // tzw_record - data source only from api
    // 会员管理模块 - 收货地址
    private static final String MEM_SHIPPING_ADDRESS = "/memberManagement/memShippingAddress"; // tzw_order_address - data source only from api
    // 会员管理模块 - 购物车
    private static final String MEM_SHOPPING_CAR = "/memberManagement/memShoppingCar"; // tzw_shopping_car - data source only from api
    // 会员管理模块 - 收藏
    private static final String MEM_COLLECT = "/memberManagement/memCollect"; // tzw_collection - data source only from api // 1商品  3文章
    // TODO 会员管理模块 - 积分管理：在后台给会员加减积分，交易明细记录到 积分明细 中。
    private static final String MEM_POINT = "/memberManagement/memPoint";
    // TODO 会员管理模块 - 抽奖券管理：将 redis 中的用户名下抽奖券信息同步到后台显示即可，要记录数据来源便于后期从后台送券。
    private static final String MEM_RAFFLE_TICKET = "/memberManagement/memRaffleTicket";

    // 抽奖管理模块 - 会员抽奖号码
    private static final String DRA_USER_NUMBER = "/drawManagement/draUserNumber"; // tzw_number
    // 抽奖管理模块 - 免费抽奖
    private static final String DRA_FREE_LOTTERY = "/drawManagement/draFreeLottery";
    // 抽奖管理模块 - 积分抽奖
    private static final String DRA_INTEGRAL_LOTTERY = "/drawManagement/draIntegralLottery";
    // TODO 抽奖管理模块 - 参与用户列表
    private static final String DRA_PARTICIPATE_MEMBER = "/drawManagement/draParticipateMember";

    // TODO 财务管理 - 财务管理
    private static final String FIN_FINANCE_MANAGE = "/financeManagement/finFinanceManage";
    // TODO 财务管理 - 对账管理
    private static final String FIN_RECONCILIATION_MANAGE = "/financeManagement/finReconciliationManage";

    // TODO 即时通讯模块 - 通讯管理
    private static final String INS_IM_MANAGE = "/instantMessaging/insMessaging";

    // 系统管理模块 - 组织管理
    private static final String SYS_ORGANIZE = "/systemManagement/sysOrganize";
    // 系统管理模块 - 角色管理
    private static final String SYS_ROLE = "/systemManagement/sysRole";
    // 系统管理模块 - 角色管理
    private static final String SYS_ROLE_MENU = "/systemManagement/sysRoleMenu";
    // 系统管理模块 - 用户管理
    private static final String SYS_USER = "/systemManagement/sysUser";
    // 系统管理模块 - 功能管理
    private static final String SYS_FUNCTION = "/systemManagement/sysFunction";
    // 系统管理模块 - 菜单管理
    private static final String SYS_MENU = "/systemManagement/sysMenu";
    // 系统管理模块 - 权限管理
    private static final String SYS_PERMISSIONS = "/systemManagement/sysPermissions";
    // 公共模块
    private static final String COMMON = "/commonManagement";

    // 阿里云 - 阿里云OSS
    private static final String ALI_OSS = "/aliyun/aliOSS";
    private static Set<String> excludeLoginUrlSet = new HashSet<>();
    private static Mono<ServerResponse> loginFailMono = ServerResponse
            .badRequest()
            .contentType(MediaType.APPLICATION_JSON)
            .body(Mono.just(ResInfo.builder()
                    .theme("login")
                    .code("fail")
                    .status(HttpStatus.UNAUTHORIZED.value())
                    .description("没有登陆")
                    .build()), ResInfo.class);
    private static Mono<ServerResponse> hasNotAuthMono = ServerResponse
            .badRequest()
            .contentType(MediaType.APPLICATION_JSON)
            .body(Mono.just(ResInfo.builder()
                    .theme("auth")
                    .code("fail")
                    .status(HttpStatus.FORBIDDEN.value())
                    .description("没有权限")
                    .build()), ResInfo.class);

    static {
        excludeLoginUrlSet.add("/systemManagement/sysUser/login/");
        excludeLoginUrlSet.add("/systemManagement/sysUser/logout/");
        excludeLoginUrlSet.add("/systemManagement/sysPermissions/export/");
    }

    // 模板管理 - 模板样式1
    private static final String TEM_STYLE1 = "/templateExample/temStyle1";

    HandlerFilterFunction<ServerResponse, ServerResponse> loginFilter = (request, next) -> {

        if (excludeLoginUrlSet.contains(request.path())) {
            return next.handle(request);
        }
        SysUser sysUser = SysUserConverter.loadLoginUserFromRequest(request);
        if (sysUser == null) {
            return loginFailMono;
        }
        if(!Services.sysPermissions.hasAuth(sysUser.getUuid(), request.path())) {
            return hasNotAuthMono;
        }
        return next.handle(request);
    };

    @Bean
    RouterFunction<ServerResponse> common(TemStyle1Handler handler) {
        return nest(path(COMMON), TemStyle1Router.funs(handler));
    }

    @Bean
    RouterFunction<ServerResponse> temStyle1(TemStyle1Handler handler) {
        return nest(path(TEM_STYLE1), TemStyle1Router.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> gooBrandRecommendGoods(GooBrandRecommendGoodsHandler handler) {
        return nest(path(GOO_BRAND_RECOMMEND_GOODS), GooBrandRecommendGoodsRouter.funs(handler));
    }

    @Bean
    RouterFunction<ServerResponse> baseGoods(BaseGoodsHandler handler) {
        return nest(path(BASE_GOODS), BaseGoodsRouter.funs(handler));
    }

    @Bean
    RouterFunction<ServerResponse> aliOSS(AliyunOSSHandler handler) {
        return nest(path(ALI_OSS), AliyunOSSRouter.funs(handler));
    }

    @Bean
    RouterFunction<ServerResponse> sysOrganize(SysOrganizeHandler handler) {
        return nest(path(SYS_ORGANIZE), SysOrganizeRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> sysRole(SysRoleHandler handler) {
        return nest(path(SYS_ROLE), SysRoleRouter.funs(handler)).filter(loginFilter);
    }
    @Bean
    RouterFunction<ServerResponse> sysRoleMenu(SysRoleMenuHandler handler) {
        return nest(path(SYS_ROLE_MENU), SysRoleMenuRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> sysUser(SysUserHandler handler) {
        return nest(path(SYS_USER), SysUserRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> sysFunction(SysFunctionHandler handler) {
        return nest(path(SYS_FUNCTION), SysFunctionRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> sysMenu(SysMenuHandler handler) {
        return nest(path(SYS_MENU), SysMenuRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> sysPermissions(SysPermissionsHandler handler) {
        return nest(path(SYS_PERMISSIONS), SysPermissionsRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> socLife(SocLifeHandler handler) {
        return nest(path(SOC_LIFE), SocLifeRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> socShow(SocShowHandler handler) {
        return nest(path(SOC_SHOW), SocShowRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> socSign(SocSignHandler handler) {
        return nest(path(SOC_SIGN), SocSignRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> socDian(SocDianzanHandler handler) {
        return nest(path(SOC_DIANZAN), SocDianzanRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> socArticle(SocArticleHandler handler) {
        return nest(path(SOC_ARTICLE), SocArticleRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> mesType(MesTypeHandler handler) {
        return nest(path(MES_TYPE), MesTypeRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> mesTemplate(MesTemplateHandler handler) {
        return nest(path(MES_TEMPLATE), MesTemplateRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> mesLog(MesLogHandler handler) {
        return nest(path(MES_LOG), MesLogRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> draUserNumber(DraUserNumberHandler handler) {
        return nest(path(DRA_USER_NUMBER), DraUserNumberRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> draFreeLottery(DraFreeLotteryHandler handler) {
        return nest(path(DRA_FREE_LOTTERY), DraFreeLotteryRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> draIntegralLottery(DraIntegralLotteryHandler handler) {
        return nest(path(DRA_INTEGRAL_LOTTERY), DraIntegralLotteryRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> conZoneTemplate(ConZoneTemplateHandler handler) {
        return nest(path(CON_ZONE_TEMPLATE), ConZoneTemplateRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> conZoneType(ConZoneTypeHandler handler) {
        return nest(path(CON_ZONE_TYPE), ConZoneTypeRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> conZoneManage(ConZoneManageHandler handler) {
        return nest(path(CON_ZONE_MANAGE), ConZoneManageRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> conSiteCounty(ConSiteCountyHandler handler) {
        return nest(path(CON_SITE_COUNTY), ConSiteCountyRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> conSiteCity(ConSiteCityHandler handler) {
        return nest(path(CON_SITE_CITY), ConSiteCityRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> conSiteProvince(ConSiteProvinceHandler handler) {
        return nest(path(CON_SITE_PROVINCE), ConSiteProvinceRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> conVersion(ConVersionHandler handler) {
        return nest(path(CON_VERSION), ConVersionRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> memMember(MemMemberHandler handler) {
        return nest(path(MEM_MEMBER), MemMemberRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> memThirdLoginInfo(MemThirdLoginInfoHandler handler) {
        return nest(path(MEM_THIRD_LOGIN_INFO), MemThirdLoginInfoRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> memJifen(MemJifenHandler handler) {
        return nest(path(MEM_JIFEN), MemJifenRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> memRecord(MemRecordHandler handler) {
        return nest(path(MEM_RECORD), MemRecordRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> memShippingAddress(MemShippingAddressHandler handler) {
        return nest(path(MEM_SHIPPING_ADDRESS), MemShippingAddressRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> memShoppingCar(MemShoppingCarHandler handler) {
        return nest(path(MEM_SHOPPING_CAR), MemShoppingCarRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> memCollect(MemCollectHandler handler) {
        return nest(path(MEM_COLLECT), MemCollectRouter.funs(handler)).filter(loginFilter);
    }


    @Bean
    RouterFunction<ServerResponse> gooGoods(GooGoodsHandler handler) {
        return nest(path(GOO_GOODS), GooGoodsRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> gooInventory(GooInventoryHandler handler) {
        return nest(path(GOO_INVENTORY), GooInventoryRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> gooBrand(GooBrandHandler handler) {
        return nest(path(GOO_BRAND), GooBrandRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> gooTypeLevel1(GooTypeLevel1Handler handler) {
        return nest(path(GOO_TYPE_LEVE1), GooTypeLevel1Router.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> gooTypeLevel2(GooTypeLevel2Handler handler) {
        return nest(path(GOO_TYPE_LEVE2), GooTypeLevel2Router.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> ordOrder(OrdOrderHandler handler) {
        return nest(path(ORD_ORDER), OrdOrderRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> ordOrderLine(OrdOrderLineHandler handler) {
        return nest(path(ORD_ORDER_LINE), OrdOrderLineRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> ordRefund(OrdRefundHandler handler) {
        return nest(path(ORD_REFUND), OrdRefundRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> orderPayDetail(OrdPayDetailHandler handler) {
        return nest(path(ORD_PAY_DETAIL), OrdPayDetailRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> ordOrderLogistics(OrdOrderLogisticsHandler handler) {
        return nest(path(ORD_ORDER_LOGISTICS), OrdOrderLogisticsRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> aftApplyOrder(AftApplyOrderHandler handler) {
        return nest(path(AFT_APPLY_ORDER), AftApplyOrderRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> aftApplyOrderLine(AftApplyOrderLineHandler handler){
        return nest(path(AFT_APPLY_ORDER_LINE), AftApplyOrderLineRouter.funs(handler)).filter(loginFilter);
    }

    //this line is work for router,don't remove
    @Bean
    RouterFunction<ServerResponse> wmsStockOutItems(WmsStockOutItemsHandler handler){
        return nest(path(WMS_STOCK_OUT_ITEMS), WmsStockOutItemsRouter.funs(handler));
    }
    @Bean
    RouterFunction<ServerResponse> wmsPurchaseOrderLine(WmsPurchaseOrderLineHandler handler){
        return nest(path(WMS_PURCHASE_ORDER_LINE), WmsPurchaseOrderLineRouter.funs(handler));
    }
    @Bean
    RouterFunction<ServerResponse> wmsStockDetailItems(WmsStockDetailItemsHandler handler){
        return nest(path(WMS_STOCK_DETAIL_ITEMS), WmsStockDetailItemsRouter.funs(handler));
    }
    @Bean
    RouterFunction<ServerResponse> memAppKey(MemAppKeyHandler handler){
        return nest(path(MEM_APP_KEY), MemAppKeyRouter.funs(handler));
    }
    @Bean
    RouterFunction<ServerResponse> gooBaseGoodsSpecificationValue(GooBaseGoodsSpecificationValueHandler handler){
        return nest(path(GOO_BASE_GOODS_SPECIFICATION_VALUE), GooBaseGoodsSpecificationValueRouter.funs(handler));
    }
    @Bean
    RouterFunction<ServerResponse> gooBaseGoodsSpecification(GooBaseGoodsSpecificationHandler handler){
        return nest(path(GOO_BASE_GOODS_SPECIFICATION), GooBaseGoodsSpecificationRouter.funs(handler));
    }
    @Bean
    RouterFunction<ServerResponse> conShareManage(ConShareManageHandler handler){
        return nest(path(CON_SHARE_MANAGE), ConShareManageRouter.funs(handler));
    }

    @Bean
    RouterFunction<ServerResponse> mesCreate(MesCreateHandler handler){
        return nest(path(MES_CREATE), MesCreateRouter.funs(handler));
    }
    @Bean
    RouterFunction<ServerResponse> conFeedback(ConFeedbackHandler handler){
        return nest(path(CON_FEEDBACK), ConFeedbackRouter.funs(handler));
    }
    @Bean
    RouterFunction<ServerResponse> memRaffleTicket(MemRaffleTicketHandler handler){
        return nest(path(MEM_RAFFLE_TICKET), MemRaffleTicketRouter.funs(handler));
    }
    @Bean
    RouterFunction<ServerResponse> memPoint(MemPointHandler handler){
        return nest(path(MEM_POINT), MemPointRouter.funs(handler));
    }
    @Bean
    RouterFunction<ServerResponse> gooOutWarehouse(GooOutWarehouseHandler handler) {
        return nest(path(GOO_OUT_WAREHOUSE), GooOutWarehouseRouter.funs(handler));
    }
    @Bean
    RouterFunction<ServerResponse> gooInWarehouse(GooInWarehouseHandler handler) {
        return nest(path(GOO_IN_WAREHOUSE), GooInWarehouseRouter.funs(handler));
    }
    @Bean
    RouterFunction<ServerResponse> gooAttributeValue(GooAttributeValueHandler handler) {
        return nest(path(GOO_ATTRIBUTE_VALUE), GooAttributeValueRouter.funs(handler)).filter(loginFilter);
    }


    @Bean
    RouterFunction<ServerResponse> gooAttribute(GooAttributeHandler handler) {
        return nest(path(GOO_ATTRIBUTE), GooAttributeRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> gooBaseGoodsAttribute(GooBaseGoodsAttributeHandler handler) {
        return nest(path(GOO_BASE_GOODS_ATTRIBUTE), GooBaseGoodsAttributeRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> gooBaseGoodsAttributeValue(GooBaseGoodsAttributeValueHandler handler) {
        return nest(path(GOO_BASE_GOODS_ATTRIBUTE_VALUE), GooBaseGoodsAttributeValueRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> insMessaging(InsMessagingHandler handler) {
        return nest(path(INS_IM_MANAGE), InsMessagingRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> finReconciliationManage(FinReconciliationManageHandler handler) {
        return nest(path(FIN_RECONCILIATION_MANAGE), FinReconciliationManageRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> finFinanceManage(FinFinanceManageHandler handler) {
        return nest(path(FIN_FINANCE_MANAGE), FinFinanceManageRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> draParticipateMember(DraParticipateMemberHandler handler) {
        return nest(path(DRA_PARTICIPATE_MEMBER), DraParticipateMemberRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> wmsWarningConfig(WmsWarningConfigHandler handler) {
        return nest(path(WMS_WARNING_CONFIG), WmsWarningConfigRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> wmsTraysManage(WmsTraysManageHandler handler) {
        return nest(path(WMS_TRAYS_MANAGE), WmsTraysManageRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> wmsWarehouseManage(WmsWarehouseManageHandler handler) {
        return nest(path(WMS_WAREHOUSE_MANAGE), WmsWarehouseManageRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> wmsStockDetail(WmsStockDetailHandler handler) {
        return nest(path(WMS_STOCK_DETAIL), WmsStockDetailRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> wmsStockOut(WmsStockOutHandler handler) {
        return nest(path(WMS_STOCK_OUT), WmsStockOutRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> wmsStockTransfer(WmsStockTransferHandler handler) {
        return nest(path(WMS_STOCK_TRANSFER), WmsStockTransferRouter.funs(handler));
    }

    @Bean
    RouterFunction<ServerResponse> wmsStockPut(WmsStockPutHandler handler) {
        return nest(path(WMS_STOCK_PUT), WmsStockPutRouter.funs(handler));
    }

    @Bean
    RouterFunction<ServerResponse> wmsPurchaseOrderThree(WmsPurchaseOrderThreeHandler handler) {
        return nest(path(WMS_PURCHASE_ORDER_THREE), WmsPurchaseOrderThreeRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> wmsPurchaseOrderSelf(WmsPurchaseOrderSelfHandler handler) {
        return nest(path(WMS_PURCHASE_ORDER_SELF), WmsPurchaseOrderSelfRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> aftWorkOrder(AftWorkOrderHandler handler) {
        return nest(path(AFT_WORK_ORDER), AftWorkOrderRouter.funs(handler)).filter(loginFilter);
    }

    @Bean
    RouterFunction<ServerResponse> versions(VersionsHandler handler) {
        return nest(path(VERSIONS), VersionsRouter.funs(handler));
    }

}


// =================
// 原版数据库表分析分类
// =================


/* DEL —— 在新版中不考虑的表 **/
//    admin_user            管理员表
//    adminuser_role        管理员角色表
//    resource              资源
//    role                  角色表
//    role_resource         角色资源表
//    tzw_item_article      文章表（外键：商品 | 抽奖）
//    tzw_yue               余额记录表

/* socialManagement: 社交管理模块 **/
//    tzw_life              觅生活晒图
//    tzw_show          	首页晒单表
//    tzw_sign          	签到设置表
//    tzw_dianzan           圈子点赞 data source only from api

/* messageManagement: 消息管理模块 **/
//    tzw_system_message  	系统消息
//    app_user_message      用户消息

/* drawManagement: 抽奖管理模块 **/
//    tzw_item_draw         抽奖商品表
//    tzw_number            会员抽奖号码 data source only from api

/* configManagement: 配置管理模块 **/
//    tzw_img               首页轮播图
//    tzw_active            活动预告
//    tzw_activey           活动首页表
//    tzw_brand             品牌表
//    tzw_new               首页最新单品
//    tzw_view          	首页视频
//    tzw_zone          	专区表
//    tzw_circle            圈子表
//    county                县
//    city                  市
//    province              省

/* memberManagement: 会员管理模块 **/
//    user                  会员
//    third_user            第三方用户表 data source only from api
//    tzw_jifen             积分记录表 data source only from api
//    tzw_record        	消费记录表 data source only from api
//    tzw_order_address    	地址表 data source only from api
//    tzw_shopping_car    	购物车表 data source only from api
//    tzw_collection        收藏表 data source only from api

/* goodsManagement: 商品管理模块 **/
//    tzw_one_type          一级分类
//    tzw_two_type        	二级分类
//    tzw_item              商品表

/* orderManagement: 订单管理模块 **/
//    tzw_pay               总支付表 data source only from api
//    tzw_order             订单表
//    tzw_order_return      售后退款表
